xen/arm: p2m: Correctly flush TLB in create_p2m_entries
authorJulien Grall <julien.grall@linaro.org>
Tue, 14 Jan 2014 13:36:55 +0000 (13:36 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 15 Jan 2014 13:16:40 +0000 (13:16 +0000)
commitc938f5414b2b7ffa5b6f65daa9f4522db360987b
treebdae7ebb1564217fa066ad6578f2173011a7dda2
parent8a9ab685bef64a50f58d99a4e8728b770289e9ef
xen/arm: p2m: Correctly flush TLB in create_p2m_entries

The p2m is shared between VCPUs for each domain. Currently Xen only flush
TLB on the local PCPU. This could result to mismatch between the mapping in the
p2m and TLBs.

Flush TLB entries used by this domain on every PCPU. The flush can also be
moved out of the loop because:
    - ALLOCATE: only called for dom0 RAM allocation, so the flush is never called
    - INSERT: if valid = 1 that would means with have replaced a
    page that already belongs to the domain. A VCPU can write on the wrong page.
    This can happen for dom0 with the 1:1 mapping because the mapping is not
    removed from the p2m.
    - REMOVE: except for grant-table (replace_grant_host_mapping), each
    call to guest_physmap_remove_page are protected by the callers via a
        get_page -> .... -> guest_physmap_remove_page -> ... -> put_page. So
    the page can't be allocated for another domain until the last put_page.
    - RELINQUISH : the domain is not running anymore so we don't care...

Also avoid leaking a foreign page if the function is INSERTed a new mapping
on top of foreign mapping.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
xen/arch/arm/p2m.c